Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI 구축 #32

Merged
merged 5 commits into from
Nov 7, 2024
Merged

CI 구축 #32

merged 5 commits into from
Nov 7, 2024

Conversation

yuncheol-AHN
Copy link
Collaborator

#️⃣ 연관된 이슈


📝 작업 내용

develop branch로 PR 시

✅ build check

✅ swiftlint check


📒 리뷰 노트

에러가 엄청 많다?


🚩 개발 과정과 ⚽️ 트러블 슈팅

일단 해보자 ☀️

⭐️ 프로젝트의 Actions에 들어갑니다 ~

Screenshot%202024-11-07%20at%2011 55 12%E2%80%AFPM

⭐️ configure button에서 yml 파일 만들고 아래의 코드를 넣어주면 [on] 조건에 따라 [jobs] 수행

image-7

⭐️ 아래는 기본이 되는 swift.yml (동작 안됨)

# This workflow will build a Swift project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift

name: My Swift Actions 🚗

on: # 언제? 어떤 이벤트?
  push: # 푸시할 때!
    branches: [ "develop" ] # develop branch에!
  pull_request: # PR할 때!
    branches: [ "develop" ] # develop branch에!

jobs: # 어떤 작업을 수행할거?
  build: # jobs name

	  runs-on: macos-latest # 작업을 수행할 OS version

    steps:
    - uses: actions/checkout@v4 # 저장소를 Sync
        
    - name: Build
      run: |
        xcodebuild -workspace ./MemorialHouse/MemorialHouse.xcworkspace -scheme MemorialHouse

actions/checkout@v4

  • Syncing repository: boostcampwm-2024/iOS10-MemorialHouse

xcodebuild -workspace ./MemorialHouse/MemorialHouse.xcworkspace -scheme MemorialHouse

  • xcodebuild command를 통해 build

⚙️ 1 Trouble

** BUILD FAILED **
Error: Error Domain=Xcode3ProjectErrorDomain Code=2 "The project ‘MHDomain’ cannot be opened because it is in a future Xcode project file format (77). Adjust the project format using a compatible version of Xcode to allow it to be opened by this version of Xcode." UserInfo={NSLocalizedDescription=The project ‘MHDomain’ cannot be opened because it is in a future Xcode project file format (77). Adjust the project format using a compatible version of Xcode to allow it to be opened by this version of Xcode.}

대충 project가 xcodebuild version을 앞선 다는 이야기 ❕

💡command line(sudo xcodebuild -version)을 통해 xcode version을 확인해주고 command line(sudo xcode-select -s /Applications/Xcode_16.1.app)을 통해 우리의 xcode version인 16.1로 변경

# ...

- name: 🔨 set up xcode version
  run: |
    sudo xcode-select -s /Applications/Xcode_16.1.app
      
- name: ✅ check xcode version
  run: |
    sudo xcodebuild -version

일단 xcode version 관련 에러는 해결했는데 swift package manager, swift lint 관련 또 다른 에러 발생

⚙️ 2 Trouble

Validate plug-in “SwiftLintBuildToolPlugin” in package “swiftlintplugins”
error: “SwiftLintBuildToolPlugin” must be enabled before it can be used
** BUILD INTERRUPTED **
The following build commands failed:
Validate plug-in “SwiftLintBuildToolPlugin” in package “swiftlintplugins”eyJ0eXBlIjp7IndvcmtzcGFjZSI6e319fQ==
(2 failures)

swiftlintplugins package의 SwiftLintBuildToolPlugin가 유효하지 않다는데 …

로컬에서도 테스트해보고 이 것 저 것 해보다가 안돼서 일단 swiftlint 관련 dependency package 제거

Swiftlint 관련 에러는 사라졌는데 다음은 어떤 에러가 …

⚙️ 3 Trouble

No signing certificate "iOS Development" found: No "iOS Development" signing certificate matching team ID "B3PWYBKFUK" with a private key was found

대충 certificate 관련 에러 … 아래의 영상과 링크 참조해서 해결

https://www.youtube.com/watch?v=Sd7YhlxZrJw

https://docs.github.com/en/actions/use-cases-and-examples/deploying/installing-an-apple-certificate-on-macos-runners-for-xcode-development

코드는 아래와 같습니다.

# This workflow will build a Swift project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift

name: My Swift Actions 🚗

on: # 언제? 어떤 이벤트?
  push: # 푸시할 때!
    branches: [ "ci" ] # ci branch에!

jobs: # 어떤 작업을 수행할거?
  build:

	  runs-on: macos-latest

    steps:
    - uses: actions/checkout@v4
    
    - name: install the Apple certificate and provisioning profile
      env:
        BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
        P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
        BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
        KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
      run: |
        # create variables
        CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
        PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
        KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db

        # import certificate and provisioning profile from secrets
        echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
        echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH

        # create temporary keychain
        security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
        security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
        security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH

        # import certificate to keychain
        security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
        security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
        security list-keychain -d user -s $KEYCHAIN_PATH

        # apply provisioning profile
        mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
        cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
    
    - name: PWD
      run: |
        pwd
        
    - name: ll
      run: |
        ls -a
        
    - name: 🔨 set up xcode version
      run: |
        sudo xcode-select -s /Applications/Xcode_16.1.app
        
    - name: ✅ check xcode version
      run: |
        sudo xcodebuild -version
        
    - name: Build
      run: |
        xcodebuild -workspace ./MemorialHouse/MemorialHouse.xcworkspace -scheme MemorialHouse 

⚙️ 4 Trouble

인증서는 등록 됐는데 이번엔 Provisioning Profiles 관련 에러가 …

테스트 하려는 device에 provisioning profiles가 있어야 실행이 된다는데 …

근데 해당 파일을 찾기 어려워서 고민하다가 팀원분들의 도움으로 … 아래의 해결책 …

xcodebuild -workspace ./MemorialHouse/MemorialHouse.xcworkspace -scheme MemorialHouse에 아래의 옵션 추가추가 ~~

-destination 'platform=iOS Simulator,name=iPhone 16 Pro'

문제 해결 ~~~ 빌드가 되었습니다.

** BUILD SUCCEEDED **

그리고 여기까지 해결하니까 swiftlint dependency package 관련 에러가 귀신같이 사라짐요 ㅋ

⚙️ 5 Trouble

아까 못했던 린트 적용 아래의 링크를 참고해 아래의 swiftlint.yml 생성

https://github.com/norio-nomura/action-swiftlint

name: swiftlint 🔨

on:
  pull_request:
    branches: ["develop"] # develop branch로 PR 올 때 actions 수행
    paths: # 아래의 파일들이 변경될 때 actions 수행
      - '.github/workflows/swiftlint.yml'
      - '.swiftlint.yml'
      - '**/*.swift'
      
jobs:
  SwiftLint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: GitHub Action for SwiftLint
        uses: norio-nomura/[email protected]
      - name: GitHub Action for SwiftLint with --strict # lint 만족X 시 ERROR
        uses: ezraberch/[email protected]
        with:
          args: --strict
      - name: GitHub Action for SwiftLint (Only files changed in the PR)
        uses: norio-nomura/[email protected]
        env:
          DIFF_BASE: ${{ github.base_ref }}
      - name: GitHub Action for SwiftLint (Different working directory)
        uses: norio-nomura/[email protected]
        env:
          WORKING_DIRECTORY: Source

아래는 린트 적용된 사진

@yuncheol-AHN yuncheol-AHN linked an issue Nov 7, 2024 that may be closed by this pull request
@yuncheol-AHN yuncheol-AHN force-pushed the feature/build-cicd branch 3 times, most recently from e83ab8b to 0946161 Compare November 7, 2024 16:09
@yuncheol-AHN yuncheol-AHN changed the title Feature/build cicd CI 구축 Nov 7, 2024
@yuncheol-AHN yuncheol-AHN self-assigned this Nov 7, 2024
@yuncheol-AHN yuncheol-AHN added the 🧱 Build 빌드 및 패키지 관련 작업 label Nov 7, 2024
@yuncheol-AHN yuncheol-AHN modified the milestones: 0.2, 0.1 Nov 7, 2024
Copy link
Collaborator

@Kyxxn Kyxxn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

진짜진짜 * 100 고생하셨습니다 !!!!!!

Copy link
Collaborator

@k2645 k2645 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이모지가 킥이네요 ~ 너무 수고 많으셨습니다 .ᐟ.ᐟ

Copy link
Collaborator

@iceHood iceHood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

킹갓갓갓 윤철님 너무 고생 많으셨습니다... ㅠㅠㅠ 감사합니다

@yuncheol-AHN yuncheol-AHN merged commit 586edb7 into develop Nov 7, 2024
2 checks passed
@yuncheol-AHN yuncheol-AHN deleted the feature/build-cicd branch November 7, 2024 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧱 Build 빌드 및 패키지 관련 작업
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI/CD 구축
4 participants